<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class rss extends CI_Controller {
	public function __construct(){
		parent::__construct();	
	}
	
	function index (){
		
	}
	
	function category($cat_code = ''){
		$data = array();
		$this->load->model("mgame");
		$this->load->model("mcategory");
		$data['cate'] = $this->mcategory->get($cat_code, 'cat_code');
		if(!$data['cate']) return '';
		$data['game'] = array();
		if($data['cate']->cat_parent ==0){
			$subcats = $this->mcategory->gets($data['cate']->cat_id, 'cat_parent');
			if($subcats){
				$arr_subcat = array();
				foreach($subcats as $subcat){
					$arr_subcat[] = $subcat->cat_id;
				}
				$data['games'] =$this->get_game($arr_subcat);
			}
		
		}
		else {
			$data['games'] =$this->get_game($data['cate']->cat_id);
		}
		$this->load->view($this->template->prefix_frontend . 'uindex/rss', $data);
	}
	
	function get_game($arr_cate = array()){
		$this->db->limit(20);
		$this->db->order_by('game_id desc');
		$this->db->where('game_status > ',0);
		return  $this->mgame->get_by_cate($arr_cate);
	}
}